home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / udpcmd.c < prev    next >
C/C++ Source or Header  |  1994-06-04  |  1KB  |  75 lines

  1. /* UDP-related user commands
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include <stdio.h>
  5. #ifdef MSDOS
  6. #include <dos.h>
  7. #endif
  8. #include "global.h"
  9. #include "mbuf.h"
  10. #include "netuser.h"
  11. #include "udp.h"
  12. #include "internet.h"
  13. #include "cmdparse.h"
  14. #include "commands.h"
  15.  
  16. static int doudpstat __ARGS((int argc,char *argv[],void *p));
  17.  
  18. static struct cmds Udpcmds[] = {
  19.     "status",    doudpstat,    0, 0,    NULLCHAR,
  20.     NULLCHAR,
  21. };
  22. int
  23. doudp(argc,argv,p)
  24. int argc;
  25. char *argv[];
  26. void *p;
  27. {
  28.     return subcmd(Udpcmds,argc,argv,p);
  29. }
  30. int
  31. st_udp(udp,n)
  32. struct udp_cb *udp;
  33. int n;
  34. {
  35.     if(n == 0)
  36. #ifdef UNIX
  37.         tprintf("&UCB Rcv-Q  Local socket\n");
  38.  
  39.     return tprintf("%8.8lx%6u  %s\n",FP_SEG(udp),udp->rcvcnt,pinet(&udp->socket));
  40. #else
  41.         tprintf("&UCB Rcv-Q  Local socket\n");
  42.  
  43.     return tprintf("%4.4x%6u  %s\n",FP_SEG(udp),udp->rcvcnt,pinet(&udp->socket));
  44. #endif
  45. }
  46.  
  47. /* Dump UDP statistics and control blocks */
  48. static int
  49. doudpstat(argc,argv,p)
  50. int argc;
  51. char *argv[];
  52. void *p;
  53. {
  54.     register struct udp_cb *udp;
  55.     register int i;
  56.  
  57.     for(i=1;i<=NUMUDPMIB;i++){
  58.         tprintf("(%2u)%-20s%10lu",i,
  59.          Udp_mib[i].name,Udp_mib[i].value.integer);
  60.         if(i % 2)
  61.             tprintf("     ");
  62.         else
  63.             tprintf("\n");
  64.     }
  65.     if((i % 2) == 0)
  66.         tprintf("\n");
  67.  
  68.     tprintf("&UCB Rcv-Q  Local socket\n");
  69.     for(udp = Udps;udp != NULLUDP; udp = udp->next){
  70.         if(st_udp(udp,1) == EOF)
  71.             return 0;
  72.     }
  73.     return 0;
  74. }
  75.